package top.hmtools.controllers;

import java.io.IOException;
import java.net.URL;
import java.util.Map;
import java.util.Map.Entry;
import java.util.ResourceBundle;

import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;
import top.hmtools.tabs.Tabs;

public class IndexController extends BaseController{
	@FXML
	private TabPane MainPane;

    /**
     * 方法说明
     * 输入参数说明
     * 输出参数说明
     */
    @Override
    public void initialize(URL location, ResourceBundle resources) {
        ObservableList<Tab> tabs = this.MainPane.getTabs();
        
        //首页选项卡页面内容
        URL url = Thread.currentThread().getContextClassLoader().getResource("viewFxml/IndexMainPane.fxml");
        FXMLLoader fxmlLoader = new FXMLLoader(url);
        Parent root = null;
        try {
            root = fxmlLoader.load();
        } catch (IOException e) {
            e.printStackTrace();
        }
        Tab mainTab = tabs.get(0);
        mainTab.setContent(root);
        
        //加载其它选项卡
        Map<String, Tabs> tabObjs = this.applicationContext.getBeansOfType(Tabs.class);
        for(Entry<String, Tabs> item:tabObjs.entrySet()){
            tabs.add(item.getValue().getTab());
        }
        
    }

}
